<?php

require_once dirname(__FILE__) . '/../lib/jobGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/jobGeneratorHelper.class.php';

/**
 * job actions.
 *
 * @package    jobeet
 * @subpackage job
 * @author     Miguel Angel Ahumada Santibáñez
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class jobActions extends autoJobActions {

    /**
     * Extender un registro de la tabla de datos
     */
    public function executeListExtend(sfWebRequest $request) {
        $job = $this->getRoute()->getObject();
        $job->extend(true);

        $this->getUser()->setFlash('notice', 'The selected jobs have been extended successfully.');

        $this->redirect('jobeet_job');
    }

    /**
     * 
     */
    public function executeListDelete(sfWebRequest $request) {
        $this->getUser()->setFlash('notice', 'The selected jobs have been delete successfully :).');

        $this->redirect('jobeet_job');
        //$this->redirect('jobeet_job');
    }

    /* Este método extiende los trabajos seleccionados en el backend */

    public function executeBatchExtend(sfWebRequest $request) {
        $ids = $request->getParameter('ids');
        //Los parametros son guardados en la variable ids  
        $q = Doctrine_Query::create()
                ->from('JobeetJob j')
                ->whereIn('j.id', $ids);

        foreach ($q->execute() as $job) {
            $job->extend(true);
        }

        $this->getUser()->setFlash('notice', 'The selected jobs have been extended successfully.');

        $this->redirect('jobeet_job');
    }

    /*     * *
     * Este lo he sobreescrito yo para evitar borrar elementos por ahora
     */

    public function executeBatchDelete(sfWebRequest $request) {
        
        //Por ahora cuando ejecute esta acción, lo voy a desautentificar
         //$this->getUser()->setAuthenticated(false);
        
        $this->getUser()->setFlash('notice', 'The selected jobs have been delete batch successfully :).');
        $this->redirect('jobeet_job');
    }

    /**
     * Método propio inventado
     * 
     */
    public function executeFoo(sfWebRequest $request) {
        $this->getUser()->setFlash('notice', 'Foo se ha ejecutado :).');
        $this->redirect('jobeet_job');
    }

}
